const path = require('path')
const Koa = require('koa')
// const bodyparser = require('koa-bodyparser')
const koaBody = require('koa-body')
const static = require('koa-static')
const cors = require('koa2-cors') // 跨域处理

const catchError = require('./middlewares/exception')
const InitManager = require('./core/init')

const app = new Koa()

app.use(catchError)
app.use(cors())
// app.use(bodyparser())
app.use(koaBody({
  multipart: true,
  formidable: {
    maxFileSize: 200*1024*1024 // 设置上传文件大小最大限制，默认2M
  }
}))
app.use(static(path.join(__dirname, './static')))

InitManager.initCore(app)

app.listen(3000, () => {
  console.log('listening on port 3000')
})